import { Local } from './storage'
import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

// 箱子配置的记住参数
export function setListQuery(bool = null) {
  return Local.set('listQuery', bool)
}
// 获取箱子配置的记住参数
export function getListQuery() {
  return Local.get('listQuery')
}
// 获取箱子配置的记住参数
export function removeListQuery() {
  return Local.remove('listQuery')
}
// 对战竞技的记住参数
export function setBattleCompetition(bool = null) {
  return Local.set('BattleCompetition', bool)
}
// 获取对战竞技的记住参数
export function getBattleCompetition() {
  return Local.get('BattleCompetition')
}
// 获取对战竞技的记住参数
export function removeBattleCompetition() {
  return Local.remove('BattleCompetition')
}
// 获取Card Battle竞技的记住参数
export function getTime_s(timestamp) {
  if (!timestamp) return ''
  const date = new Date(parseInt(timestamp))
  // let date = new Date(parseInt(timestamp) * 1000)
  const Year = date.getFullYear()
  const Moth =
      date.getMonth() + 1 < 10
        ? '0' + (date.getMonth() + 1)
        : date.getMonth() + 1
  const Day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
  const Hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
  const Minute =
      date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
  const Sechond =
      date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
  const GMT =
      Year +
      '-' +
      Moth +
      '-' +
      Day +
      '   ' +
      Hour +
      ':' +
      Minute +
      ':' +
      Sechond
  return GMT
}